getApp();

var dataApi = require("../../provider/dataApi.js");

Page({
    data: {
        statusBarHeight: "",
        titleBarHeight: "",
        viewHeight: "",
        params: {},
        info: {}
    },
    onLoad: function(options) {
        this.setData({
            statusBarHeight: getApp().globalData.statusBarHeight,
            titleBarHeight: getApp().globalData.titleBarHeight,
            viewHeight: wx.getSystemInfoSync().windowHeight
        }), "{}" != JSON.stringify(options) && this.setData({
            params: options
        }), console.log(this.data.params);
    },
    getExamInfo: function(paperId) {
        var self = this;
        dataApi.examInfo({
            uid: wx.getStorageSync("uid"),
            paper_id: paperId
        }).then(function(response) {
            console.log(response), self.setData({
                info: response.data.list
            });
        }).catch(function(error) {
            console.log(error);
        });
    },
    goBack: function() {
        wx.navigateBack({
            delta: 1
        });
    },
    goExam: function() {
        var examInfo = this.data.info;
        1 != examInfo.is_repeat && 0 < examInfo.do_number ? wx.showToast({
            title: "不可重复答题",
            icon: "none"
        }) : wx.navigateTo({
            url: "../exam/exam?exam_type=1&paperid=" + this.data.params.paperid + "&time=" + this.data.info.times
        });
    },
    onReady: function() {},
    onShow: function() {
        this.getExamInfo(this.data.params.paperid);
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});